package com.jingogo.service.impl;

import com.jingogo.common.BusinessException;
import com.jingogo.entity.Promotion;
import com.jingogo.mapper.PromotionMapper;
import com.jingogo.service.PromotionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class PromotionServiceImpl implements PromotionService {
    @Autowired
    private PromotionMapper promotionMapper;

    @Override
    public void addPromotion(Promotion promotion) {
        if (promotion.getTitle() == null || promotion.getType() == null) {
            throw new BusinessException("促销类型和标题不能为空");
        }
        promotionMapper.insert(promotion);
    }

    @Override
    public List<Promotion> listPromotions() {
        return promotionMapper.selectAll();
    }
} 